home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8507.arc / SORT.COB < prev    next >
Text File  |  1986-09-14  |  4KB  |  129 lines

  1.        IDENTIFICATION DIVISION.
  2.        PROGRAM-ID.     SORT.
  3.       *        SORT BENCHMARK
  4.  
  5.        ENVIRONMENT DIVISION.
  6.        CONFIGURATION SECTION.
  7.        SOURCE-COMPUTER.  IBM-PC.
  8.        OBJECT-COMPUTER.  IBM-PC.
  9.       *
  10.        INPUT-OUTPUT SECTION.
  11.        FILE-CONTROL.
  12.  
  13.            SELECT IN-FILE
  14.       * FOLLOWING 2 LINES FOR MICRSOFT
  15.                   ASSIGN TO  DISK
  16.                   ORGANIZATION RELATIVE
  17.  
  18.       * FOLLOWING 2 LINES FOR MICRO FOCUS & DRI
  19.       *           ASSIGN TO "B:FILE1.SEQ"
  20.       *           ORGANIZATION SEQUENTIAL
  21.  
  22.                   ACCESS SEQUENTIAL.
  23.  
  24.            SELECT SORT-WORK
  25.       * FOLLOWING LINE FOR MICRSOFT
  26.                   ASSIGN TO  DISK.
  27.  
  28.       * FOLLOWING LINE FOR MICRO FOCUS & DRI
  29.       *           ASSIGN TO "A:SORT.WRK".
  30.  
  31.            SELECT OUT-FILE
  32.       * FOLLOWING 2 LINES FOR MICRSOFT
  33.                   ASSIGN TO  DISK
  34.                   ORGANIZATION RELATIVE
  35.  
  36.       * FOLLOWING 2 LINES FOR MICRO FOCUS & DRI
  37.       *           ASSIGN TO "B:FILE1.SEQ"
  38.       *           ORGANIZATION SEQUENTIAL
  39.  
  40.                   ACCESS SEQUENTIAL.
  41.  
  42.        DATA DIVISION.
  43.        FILE SECTION.
  44.        FD  IN-FILE LABEL RECORDS ARE STANDARD
  45.       * FOLLOWING LINE FOR MICROSOFT ONLY
  46.            VALUE OF FILE-ID IS "B:FILE1.SEQ"
  47.  
  48.            DATA RECORD IS RECORD-1.
  49.  
  50.        01  RECORD-1.
  51.            05  SEQ-REC-WORD               PIC X(7).
  52.            05  SEQ-REC-NUM                PIC 9(10).
  53.            05  SEQ-REC-TAIL               PIC X(83).
  54.  
  55.        FD  OUT-FILE LABEL RECORDS ARE STANDARD
  56.       * FOLLOWING LINE FOR MICROSOFT ONLY
  57.            VALUE OF FILE-ID IS "B:FILE2.SEQ"
  58.  
  59.            DATA RECORD IS RECORD-2.
  60.  
  61.        01  RECORD-2                       PIC X(100).
  62.  
  63.        SD  SORT-WORK
  64.       * FOLLOWING LINE FOR MICROSOFT ONLY
  65.            VALUE OF FILE-ID IS "B:SORT.WRK"
  66.  
  67.            DATA RECORD IS SORT-RECORD.
  68.  
  69.        01  SORT-RECORD.
  70.            05  SORT-REC-WORD               PIC X(7).
  71.            05  SORT-REC-NUM                PIC 9(10).
  72.            05  SORT-REC-TAIL               PIC X(83).
  73.  
  74.        WORKING-STORAGE SECTION.
  75.        77  REC-LIMIT                      PIC 9999.
  76.        77  HALF-WAY                       PIC 9999.
  77.        77  COUNTER-1                      PIC 9999.
  78.        77  COUNTER-2                      PIC 9999.
  79.  
  80.            COPY TIMERDAT.
  81.  
  82.        PROCEDURE DIVISION.
  83.        000-MAINLINE.
  84.            PERFORM 100-WRITE-FILE THRU 100-EXIT.
  85.            PERFORM 200-SORT-FILE  THRU 200-EXIT.
  86.            STOP RUN.
  87.  
  88.        100-WRITE-FILE.
  89.            DISPLAY "Enter record count, 50 - 1000".
  90.            ACCEPT REC-LIMIT.
  91.            OPEN OUTPUT IN-FILE.
  92.            COMPUTE HALF-WAY = REC-LIMIT / 2.
  93.            MOVE HALF-WAY TO COUNTER-1.
  94.            ADD  HALF-WAY 1 GIVING COUNTER-2.
  95.            DISPLAY "Writing sort input, No. recs = ", REC-LIMIT.
  96.            ACCEPT TIMER-START FROM TIME.
  97.            PERFORM 120-WRITE-LOOP THRU 120-EXIT HALF-WAY TIMES.
  98.            CLOSE IN-FILE.
  99.            ACCEPT TIMER-END FROM TIME.
  100.            PERFORM 2400-CALC-TIME THRU 2400-EXIT.
  101.            DISPLAY ELAPSED-TIME.
  102.        100-EXIT.   EXIT.
  103.  
  104.        120-WRITE-LOOP.
  105.            MOVE "RECORD"  TO SEQ-REC-WORD.
  106.            MOVE COUNTER-1 TO SEQ-REC-NUM.
  107.            MOVE SPACES    TO SEQ-REC-TAIL.
  108.            WRITE RECORD-1.
  109.            MOVE "RECORD"  TO SEQ-REC-WORD.
  110.            MOVE COUNTER-2 TO SEQ-REC-NUM.
  111.            MOVE SPACES    TO SEQ-REC-TAIL.
  112.            WRITE RECORD-1.
  113.            SUBTRACT 1 FROM COUNTER-1.
  114.            ADD      1 TO   COUNTER-2.
  115.        120-EXIT.    EXIT.
  116.  
  117.        200-SORT-FILE.
  118.            DISPLAY "Beginning Sort".
  119.            ACCEPT TIMER-START FROM TIME.
  120.            SORT SORT-WORK ON ASCENDING KEY SORT-REC-NUM
  121.               USING IN-FILE GIVING OUT-FILE.
  122.            ACCEPT TIMER-END FROM TIME.
  123.            PERFORM 2400-CALC-TIME THRU 2400-EXIT.
  124.            DISPLAY ELAPSED-TIME.
  125.        200-EXIT.   EXIT.
  126.  
  127.  
  128.            COPY TIMERPRO.
  129.